package com.sk.restree.model.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sk.restree.model.dao.MemberDAO;
import com.sk.restree.model.dto.MemberDTO;

public class MemberLoginAction implements Action {

	@Override
	public Object execute(HttpServletRequest request,
			HttpServletResponse response) {
		HttpSession session = request.getSession();
		if (session.getAttribute("userinfo") != null) {
			return session.getAttribute("userinfo");
		}
		String member_id = request.getParameter("member_id");
		String pw = request.getParameter("pw");
		MemberDTO dto = MemberDAO.getInstance().login(member_id, pw);
		session.setAttribute("userinfo", dto);
		return dto;
	}

}
